package com.four.bmm.controller;

import com.four.bmm.entity.Reply;
import com.four.bmm.service.ReplyService;
import com.four.bmm.util.JsonUtil;
import com.four.bmm.util.Pagnation;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ShowReplyListServlet")
public class ShowReplyListServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          int newsid= Integer.parseInt(req.getParameter("newsid"));
          int pageIndex=Integer.parseInt(req.getParameter("pageIndex"));
        ReplyService replyService=new ReplyService();
        Pagnation<Reply> pg=replyService.getNewsReplyListByPage(newsid,pageIndex);
        /*Pagnation<Reply> pag=replyService.getUserReplyListByPage();*/
        JsonUtil.toJson(resp,pg);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
